// develop_loader.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include "../../loader.h"

using namespace dlguif;
using std::cout;
using std::endl;

Loader loader; 

void OnText(void * userptr,const char* text)
{
	printf("%s\n", text);
}


 
void CALLBACK OnGui(void* user_context,  const callback_info* ci)
{
	static int count = 0;
	count ++;
	cout << "OnCui:  " << count <<  endl;


	if(ci->eventType == EVENT_TYPE_FORM_CLOSE)
	{
		loader.PostExit(0);
	}
}
 

int _tmain(int argc, _TCHAR* argv[])
{
 
	loader.SetGuiEventCallBack(OnGui , NULL);
 
   // create form
   HRESULT hr=0;
   void* pform = NULL;
   RECT rec_form = { 10, 10, 860, 660 };	// left; top; right;  bottom; 
   pform = loader.CreateForm( "caption", "myform", &rec_form );

   // create group
   void* pGrpbox = NULL;
   RECT recGropup = {5, 5, 600, 500};
   hr |= loader.CreateGroupBox(&pGrpbox, "mygroup", pform, pform, &recGropup );

   // create button
   void* pbutton = NULL;
   RECT recButton;
   Loader::SetRectangle(recButton, 10, 20, 60, 20 );
   hr |= loader.CreateButton(&pbutton, "mybutton", pform, pGrpbox, &recButton);

   // checkbox
   void* pcheck = NULL;
   //RECT recCheck;
   //Loader::SetRectangle(recCheck, 10, 50,)
   hr |= loader.CreateCheckBox(&pcheck, pform, pGrpbox, "ckeckbox", 10, 60, true);

   // label
   void* plabel = NULL;
   hr |= loader.CreateLabel(&plabel, pform, pGrpbox, "mylabel", true, 10, 100);

   // radioitems
   void* pradioitems = NULL;
   hr |= loader.CreateRadioItems(&pradioitems, pform, pGrpbox, "caption", 
	   "0000\n11111\n2222222\n333333", -1, 10, 130);

   // edit
   void* pEdit = NULL;
   hr |= loader.CreateEdit(&pEdit, pform, pGrpbox, 10, 240, 100, "mytext");

   // slider
   void* pSLider = NULL;
   hr |= loader.CreateSlider(&pSLider, pform, pGrpbox, 10, 270, 200, false, 0, 100, 50);

   // memo
   void* pmemo = NULL;
   hr |= loader.CreateMemo(&pmemo, pform, pGrpbox , 
	   &Loader::MakeRectangle(200, 100, 300, 90), "text"  );

   // listbox
   void* plistbox;
   hr |= loader.CreateListBox(&plistbox, pform, pGrpbox, 
	   &Loader::MakeRectangle(10, 310, 100, 100), 
	   "000\n11111\n222222\n333333\n44444", -1   );

   // updown
   void* pUpDown = NULL;
   hr |= loader.CreateUpDown(&pUpDown, pform, pGrpbox, 
	   &Loader::MakeRectangle(200, 200, 25, 25 ), true   );


   // spinedit
   void* pspin = NULL;
   hr |= loader.CreateSpinEdit(&pspin, pform, pGrpbox, 200, 230,  60);

   // combobox
   void* pcbox = NULL;
   hr |= loader.CreateComboBox(&pcbox, pform, pGrpbox, 
	   "000\n11111\n22222\n33333", 0, 200, 20, 100 );

   void* pnl = loader.CreatePanel(pform, pGrpbox, &Loader::MakeRectangle( 300, 300, 30, 30 ));


   // main menu
   {
	   void* pmm =  loader.CreateMainMenu(pform);

	   loader.CreateMainMenuItem(pmm, NULL, "file");
	   loader.CreateMainMenuItem(pmm, NULL, "some");
	   loader.CreateMainMenuItem(pmm, NULL, "help");

	    // create subitems
		loader.CreateMainMenuItem(pmm, "file", "open");
		loader.CreateMainMenuItem(pmm, "file", "close");
		loader.CreateMainMenuItem(pmm, "file", "open");
		loader.CreateMainMenuItem(pmm, "file", "-");
		loader.CreateMainMenuItem(pmm, "file", "exit");

		loader.CreateMainMenuItem(pmm, "some", "do");

		loader.CreateMainMenuItem(pmm, "help", "content");
		loader.CreateMainMenuItem(pmm, "help", "-");
		loader.CreateMainMenuItem(pmm, "help", "about");





   }

   loader.ShowForm(pform); 

   while(loader.ProcessMessages())
   {
	   Sleep(1);
   }
 
	return 0;
}

